/*
 * Inspiration: http://www.antonioshome.net/kitchen/swingnbrcp/swingnbrcp-nodes3.php
 */

package org.tintuna.cca.node;

import java.util.Collections;
import java.util.List;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.tintuna.cca.data.Spreadsheet;
import org.tintuna.cca.data.Spreadsheet;

/**
 *
 * @author bsmith
 */

public class SpreadsheetListChildren
  extends Children.Keys<Spreadsheet>
{
  private List<Spreadsheet> spreadsheets;
  
  public SpreadsheetListChildren( List<Spreadsheet> spreadsheets )
  {
    super();
    this.spreadsheets = spreadsheets;
  }

  @Override
  protected void addNotify()
  {
    super.addNotify();
    // Set the set of entities that this node represents
    setKeys( spreadsheets );
  }
  @Override
  protected void removeNotify()
  {
    // Use an empty set to clean up
    // the list of entities that this node represents
    setKeys( Collections.<Spreadsheet>emptySet() );
    super.removeNotify();
  }

    @Override
    protected Node[] createNodes(Spreadsheet spreadsheet) {
        return new Node[] { new SpreadsheetNode(spreadsheet) };
    }
}
